package bit.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bit.dao.MemberDAO;

public class MemberListAction implements Action {
	
	private MemberDAO dao;

	public MemberListAction(MemberDAO dao) {
		this.dao = dao;
	}

	@Override
	public ActionForward execute(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {
		
		String json = dao.getAllList();
		req.setAttribute("json", json);
		
		ActionForward forward = new ActionForward();
		forward.setPath("./member/list.jsp");
		forward.setRedirect(false);
		
		res.setCharacterEncoding("euc-kr");
		PrintWriter out = res.getWriter();
		out.println(json);
		
		return forward;
	}

}
